<template>
	<view class="choose-page" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd">
		<!-- <tabControl :current="current" :values="items" bgc="#3b8bfe" :scrollFlag='true' :isEqually='true'
			@clickItem="onClickItem"></tabControl> -->
		<!-- <swiper class="swiper" style="height: 100%;" @change='scollSwiper' :current='current'>
			<swiper-item v-for="(item,index) in items" :key='index'> -->
		<!-- 使用 scroll-view 来滚动内容区域 -->
		<scroll-view scroll-y="true" style="height: 100%;">
			<view class="choose-bg">
				<view v-if="current === 0">
					<view class="choose-wrap">
						<uni-list>
							<uni-list-item thumb="/static/img/custom/choose_03.png" title="关键词" note="添加关键词，商机更齐全！"
								@clickFn="keywords">
								<template v-slot:right="">
									<view class="choose-text uni-ellipsis">{{keyword}}</view>
								</template>
							</uni-list-item>
							<uni-list-item thumb="/static/img/custom/choose_06.png" title="信息类型" note="填写信息类型，让您更省力!"
								@clickFn="togglePopup('bottom', 'share')">
								<template v-slot:right="">
									<view class="choose-text uni-ellipsis">
										{{zhaobiaotypetostr(newstype.toString())}}
									</view>
								</template>
							</uni-list-item>
							<uni-list-item thumb="/static/img/custom/choose_09.png" title="查询范围" note="选择业务所在区域！"
								@clickFn="togglePopup('bottom', 'popup')">
								<template v-slot:right=""> 	
									<view class="uni-ellipsis choose-text">{{fanwei}}</view>
								</template>
							</uni-list-item>
							<uni-list-item thumb="/static/img/custom/choose_13.png" title="关注地区" note="选择您想要关注的地区"
								@clickFn="togglePopup('bottom', 'popup2')">
								<template v-slot:right="">
									<view class="choose-text uni-ellipsis ">{{newsdiqu.toString()}}</view>
								</template>
							</uni-list-item>
						</uni-list>
					</view>
					<view class="line"></view>
					<view class="choose-wrap">
						<uni-list>
							<uni-list-item thumb="/static/img/custom/choose_16.png" title="推送提醒" note="开启APP推送，让商机智能起来！"
								:show-switch="true" @switchChange="appswitchChange" :showArrow="false"
								:switchChecked="appswitch"></uni-list-item>
								
							<!-- 
								短信推送：app短信订阅再加一个限制，付费的移动端会员，生效且享有短信推送功能 张珈铭
								注：仅对移动端付费用户开放该功能且会员到期后短信推送不生效
							 -->
							<uni-list-item thumb="/static/img/custom/choose_16.png" title="短信推送" note="请将信息号码加入短信息白名单"
								:show-switch="true" @switchChange="appInfoswitchChange" :showArrow="false"
								:switchChecked="infoswitch" v-if="isshowInfoSwitch"></uni-list-item>
							<uni-list-item thumb="/static/img/custom/choose_18.png" title="推送时间" note="选择推送时间，让您掌握一手资源！"
								@clickFn="togglePopup('bottom', 'popup3')">
								<template v-slot:right="">
									<view class="uni-ellipsis choose-text">
										{{apptype===0?'全天':stime+':00--'+etime+':00'}}
									</view>
								</template>
							</uni-list-item>
						</uni-list>
					</view>
					<view style="width: 100%; padding: 50rpx 0;">
						<button class="wszl-btn" @click="submit_zhaobiao">完成</button>
					</view>
				</view>

				<view v-else>
					<view class="choose-wrap">
						<uni-list>
							<uni-list-item thumb="/static/img/custom/choose_13.png" title="感兴趣的区域" note="这里是您感兴趣的区域"
								@clickFn="togglePopup('bottom', 'popup5')">
								<template v-slot:right="">
									<view class="uni-ellipsis choose-text">{{xiangmudiqu.toString()}}</view>
								</template>
							</uni-list-item>

							<uni-list-item thumb="/static/img/custom/choose_19.png" title="项目类型" note="填写项目类型，让您更省力!"
								@clickFn="xiangmuhangye">
								<template v-slot:right="">
									<view class="uni-ellipsis choose-text">{{typetostr(xiangmutype.toString())}}
									</view>
								</template>
							</uni-list-item>
							<uni-list-item thumb="/static/img/custom/choose_20.png" title="项目阶段" note="随时查看，项目阶段信息"
								@clickFn="togglePopup('bottom', 'popup4')">
								<template v-slot:right="">
									<view class="uni-ellipsis choose-text">
										{{jieduantostr(xmjieduan.toString())}}
									</view>
								</template>
							</uni-list-item>
							<uni-list-item thumb="/static/img/custom/choose_03.png" title="客户主营业务描述" note="描述您的业务，让您更省时"
								@clickFn="description">
								<template v-slot:right="">
									<view class="uni-ellipsis choose-text">{{yewudesc}}</view>
								</template>
							</uni-list-item>
						</uni-list>
					</view>
					<view class="line"></view>
					<view class="choose-wrap">
						<uni-list>
							<uni-list-item thumb="/static/img/custom/choose_16.png" title="推送提醒" note="开启商推送，让商机智能起来！"
								:show-switch="true" @switchChange="switchChange" :showArrow="false"
								:switchChecked="xmswitch"></uni-list-item>
							<!-- 短信推送：app短信订阅再加一个限制，付费的移动端会员，生效且享有短信推送功能 张珈铭 -->
							<!-- 项目订阅中先不加此功能 -->
							<!-- <uni-list-item thumb="/static/img/custom/choose_16.png" title="短信推送" note="请将信息号码加入短信息白名单"
								:show-switch="true" @switchChange="appInfoswitchChange" :showArrow="false"
								:switchChecked="infoswitch"></uni-list-item> -->
							<uni-list-item thumb="/static/img/custom/choose_18.png" title="推送时间" note="选择推送时间，让您掌握一手资源！"
								@clickFn="togglePopup('bottom', 'popup6')">
								<template v-slot:right="">
									<view class="uni-ellipsis choose-text">
										{{xmapptype===0?'全天':xmstime+':00--'+xmetime+':00'}}
									</view>
								</template>
							</uni-list-item>
						</uni-list>
					</view>
					<view style="width: 100%; padding: 50rpx 0;">
						<button class="wszl-btn" @click="submit_xiangmu()">完成</button>
					</view>
				</view>
			</view>
		</scroll-view>
		<!-- </swiper-item>
		</swiper> -->
		<!-- 信息类型 -->
		<uni-popup ref="showshare" :type="type" :mask-click="true">
			<view class="Information-type">
				<view class="Information-title">不限类型</view>
				<view class="Information-wrap">
					<view class="Information-wrap-tabbar">
						<view class="tabbar-item tabbar-item_current">信息类型</view>
					</view>
					<view class="Information-wrap-tabtext">
						<scroll-view scroll-y="true" class="scroll-Y">
							<view style="padding: 0 20rpx;">
								<u-checkbox-group
									v-model="newstype"
									placement="column"
									iconPlacement="right" 
									shape="circle"
									@change="onGroupChange"
								>
									<u-checkbox
										:customStyle="{marginBottom: '8px',paddingTop:'10rpx', paddingBottom:'10rpx'}"
										v-for="(infortype,index) in infortypes" :key="infortype.value"
										:label="infortype.title"
										:name="infortype.value"
									
									>
									</u-checkbox>
								</u-checkbox-group>
							</view>
							
						</scroll-view>
					</view>
				</view>
				<view class="information-btn">
					<view class="btn-reset" @click="resetbutton('leixing')">重置</view>
					<view class="btn-confirm" @click="queren('leixing')">确认</view>
				</view>
			</view>
		</uni-popup>
		<!-- 查询范围 -->
		<uni-popup ref="showpopup" :type="type">
			<view class="query-popup">
				<view class="query-title">请选择查询范围</view>
				<!-- v-model="searchfanwei" -->
				<radio-group @change="fanweiradioChange" >
					<label class="uni-list-cell uni-list-cell-pd" v-for="(query, index) in querys" :key="query.value">
						<view>{{query.name}}</view>
						<view>
							<radio :value="query.value" :checked="index == currentfanwei" />
						</view>
					</label>
				</radio-group>
				<view class="query-btn" @click="queren('fanwei')">完成</view>
			</view>
		</uni-popup>
		<!-- 地区 -->
		<uni-popup ref="showpopup2" :type="type" :mask-click="true">
			<view class="areapopup">
				<view class="Information-title-search"
					style="text-align: left; padding:20rpx 30rpx;  border-top: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5;">
					地区选择</view>
				<view class="Information-wrap">
					<view class="Information-wrap-tabbar">
						<scroll-view scroll-y="true" style="height: 600rpx;">
							<view :class="currentquyu==''?'tabbar-item active':'tabbar-item'" @click="diquchange()">全国
							</view>
							<view
								:class="['tabbar-item', { 'active': currentquyu==region_1.region_id , 'current': checkCurrentProvince(region_1.region_id) }]"
								v-for="(region_1,index) in regionJson" :key="index" @click="diquchange(region_1)">
								{{region_1.region_name}}
							</view>

						</scroll-view>
					</view>
					<view class="Information-wrap-tabtext">
						<scroll-view scroll-y="true">
							<view style="display: flex; flex-wrap: wrap; flex-direction: row; margin-left: 10rpx;">
								<view v-if="currentquyu==''" class="urban-list urban-all active">全国</view>
								<view v-else
									:class="checkAllCity(currentquyu)?'urban-list urban-all active':'urban-list urban-all'"
									@click="cityChange()">本地区所有城市</view>
								<view @click="cityChange(area)"
									:class="isInArray(cityCheckedArray,area.region_id) ?'urban-list active':'urban-list'"
									v-for="(area,index) in arealist" :key="area.value">
									{{ area.region_name }}
								</view>

							</view>
						</scroll-view>
					</view>
				</view>
				<view class="information-btn">
					<view class="btn-reset" @click="resetbutton('diqu')">重置</view>
					<view class="btn-confirm" @click="queren('diqu')">确认</view>
				</view>
			</view>
		</uni-popup>
		<!-- 推送时间 -->
		<uni-popup ref="showpopup3" :type="type" :mask-click="true">
			<view class="data-popup">
				<view class="data-top-title1">选择推送时间</view>
				<view class="data-top-title2">项目订阅，及时推送不漏标！</view>
				<view class="data-wrap">
					<view class="data-star">
						<view class="data-item-title">开始时间</view>
						<view class="picker-view-mask" style="background-size: 100% 102px;"></view>
						<view class="picker-view-indicator"></view>
						<scroll-view scroll-y="true" style="height: 200rpx;">
							<view class="data-item-text">
								<text :class="[this.stime=='8'?'item-text_on':'']" @click="stimechange"
									data-val=8>08:00</text>
								<text :class="[this.stime=='9'?'item-text_on':'']" @click="stimechange"
									data-val=9>09:00</text>
								<text :class="[this.stime=='10'?'item-text_on':'']" @click="stimechange"
									data-val=10>10:00</text>
								<text :class="[this.stime=='11'?'item-text_on':'']" @click="stimechange"
									data-val=11>11:00</text>
								<text :class="[this.stime=='12'?'item-text_on':'']" @click="stimechange"
									data-val=12>12:00</text>
								<text :class="[this.stime=='13'?'item-text_on':'']" @click="stimechange"
									data-val=13>13:00</text>
								<text :class="[this.stime=='14'?'item-text_on':'']" @click="stimechange"
									data-val=14>14:00</text>
								<text :class="[this.stime=='15'?'item-text_on':'']" @click="stimechange"
									data-val=15>15:00</text>
								<text :class="[this.stime=='16'?'item-text_on':'']" @click="stimechange"
									data-val=16>16:00</text>
								<text :class="[this.stime=='17'?'item-text_on':'']" @click="stimechange"
									data-val=17>17:00</text>
								<text :class="[this.stime=='18'?'item-text_on':'']" @click="stimechange"
									data-val=18>18:00</text>
								<text :class="[this.stime=='19'?'item-text_on':'']" @click="stimechange"
									data-val=19>19:00</text>
								<text :class="[this.stime=='20'?'item-text_on':'']" @click="stimechange"
									data-val=20>20:00</text>
							</view>
						</scroll-view>
					</view>
					<view style="flex: 1 1 0%; text-align: center;">至</view>
					<view class="data-star">
						<view class="data-item-title">结束时间</view>
						<scroll-view scroll-y="true" style="height: 200rpx;">
							<view class="data-item-text">
								<text :class="[this.etime=='8'?'item-text_on':'']" @click="etimechange"
									data-val=8>08:00</text>
								<text :class="[this.etime=='9'?'item-text_on':'']" @click="etimechange"
									data-val=9>09:00</text>
								<text :class="[this.etime=='10'?'item-text_on':'']" @click="etimechange"
									data-val=10>10:00</text>
								<text :class="[this.etime=='11'?'item-text_on':'']" @click="etimechange"
									data-val=11>11:00</text>
								<text :class="[this.etime=='12'?'item-text_on':'']" @click="etimechange"
									data-val=12>12:00</text>
								<text :class="[this.etime=='13'?'item-text_on':'']" @click="etimechange"
									data-val=13>13:00</text>
								<text :class="[this.etime=='14'?'item-text_on':'']" @click="etimechange"
									data-val=14>14:00</text>
								<text :class="[this.etime=='15'?'item-text_on':'']" @click="etimechange"
									data-val=15>15:00</text>
								<text :class="[this.etime=='16'?'item-text_on':'']" @click="etimechange"
									data-val=16>16:00</text>
								<text :class="[this.etime=='17'?'item-text_on':'']" @click="etimechange"
									data-val=17>17:00</text>
								<text :class="[this.etime=='18'?'item-text_on':'']" @click="etimechange"
									data-val=18>18:00</text>
								<text :class="[this.etime=='19'?'item-text_on':'']" @click="etimechange"
									data-val=19>19:00</text>
								<text :class="[this.etime=='20'?'item-text_on':'']" @click="etimechange"
									data-val=20>20:00</text>
							</view>
						</scroll-view>
					</view>
				</view>
				<view class="data-btn">
					<button type="primary" @click="queren('time')">确定</button>
					<button type="primary" plain="true" @click="quantian">默认全天</button>
				</view>
			</view>
		</uni-popup>
		<!-- 项目阶段 -->
		<uni-popup ref="showpopup4" :type="type">
			<view class="query-popup">
				<view class="query-title">请选择项目阶段</view>
				<scroll-view scroll-y="true" style="height: 500rpx;">
					<view style="padding: 0 20rpx;">
						<u-checkbox-group
							placement="column"
							iconPlacement="right" 
							shape="circle"
							@change="xmjieduanChange" 
							v-model="xmjieduan"
						>
							<u-checkbox
								:customStyle="{marginBottom: '8px',paddingTop:'10rpx', paddingBottom:'10rpx'}"
								v-for="(phase, index) in phases" :key="phase.value"
								:label="phase.title"
								:name="phase.value"
							
							>
							</u-checkbox>
						</u-checkbox-group>
					</view>
					
				</scroll-view>
				<view class="query-btn" @click="queren('jieduan')">完成</view>
			</view>
		</uni-popup>

		<!-- 工程订阅地区选择 -->
		<uni-popup ref="showpopup5" :type="type" :mask-click="true">
			<view class="areapopup">
				<view class="Information-title">不限区域</view>
				<view class="Information-wrap">
					<view class="Information-wrap-tabbar">
						<scroll-view scroll-y="true" class="scroll-Y">
							<view class="tabbar-item" :class="{tabbar_current:xiangmucurrentquyu=='全国'}"
								@click="xiangmudiquchange('全国')">全国</view>
							<view class="tabbar-item" :class="{tabbar_current:xiangmucurrentquyu=='华东'}"
								@click="xiangmudiquchange('华东')">华东</view>
							<view class="tabbar-item" :class="{tabbar_current:xiangmucurrentquyu=='华北'}"
								@click="xiangmudiquchange('华北')">华北</view>
							<view class="tabbar-item" :class="{tabbar_current:xiangmucurrentquyu=='东北'}"
								@click="xiangmudiquchange('东北')">东北</view>
							<view class="tabbar-item" :class="{tabbar_current:xiangmucurrentquyu=='华南'}"
								@click="xiangmudiquchange('华南')">华南</view>
							<view class="tabbar-item" :class="{tabbar_current:xiangmucurrentquyu=='西北'}"
								@click="xiangmudiquchange('西北')">西北</view>
							<view class="tabbar-item" :class="{tabbar_current:xiangmucurrentquyu=='西南'}"
								@click="xiangmudiquchange('西南')">西南</view>
							<view class="tabbar-item" :class="{tabbar_current:xiangmucurrentquyu=='华中'}"
								@click="xiangmudiquchange('华中')">华中</view>
						</scroll-view>

					</view>
					<view class="Information-wrap-tabtext">
						<scroll-view scroll-y="true" class="scroll-Y">
							<view style="padding: 0 20rpx;">
								<u-checkbox-group
									v-model="xiangmudiqu"
									placement="column"
									iconPlacement="right" 
									shape="circle"
									@change="onXiangmuDiquChange"
								>
									<u-checkbox
										:customStyle="{marginBottom: '8px',paddingTop:'10rpx', paddingBottom:'10rpx'}"
										v-for="(area,index) in xiangmuarealist" :key="area.value"
										:label="area.title"
										:name="area.value"
									
									>
									</u-checkbox>
								</u-checkbox-group>
							</view>
						</scroll-view>
					</view>
				</view>
				<view class="information-btn">
					<view class="btn-reset" @click="resetbutton('xmdiqu')">重置</view>
					<view class="btn-confirm" @click="queren('xmdiqu')">确认</view>
				</view>
			</view>
		</uni-popup>
		<!-- 推送时间 -->
		<uni-popup ref="showpopup6" :type="type" :mask-click="true">
			<view class="data-popup">
				<view class="data-top-title1">选择推送时间</view>
				<view class="data-top-title2">项目订阅，及时推送不漏标！</view>
				<view class="data-wrap">
					<view class="data-star">
						<view class="data-item-title">开始时间</view>
						<view class="picker-view-mask" style="background-size: 100% 102px;"></view>
						<view class="picker-view-indicator"></view>
						<scroll-view scroll-y="true" style="height: 200rpx;">
							<view class="data-item-text">
								<text :class="[this.xmstime=='8'?'item-text_on':'']" @click="xmstimechange"
									data-val=8>08:00</text>
								<text :class="[this.xmstime=='9'?'item-text_on':'']" @click="xmstimechange"
									data-val=9>09:00</text>
								<text :class="[this.xmstime=='10'?'item-text_on':'']" @click="xmstimechange"
									data-val=10>10:00</text>
								<text :class="[this.xmstime=='11'?'item-text_on':'']" @click="xmstimechange"
									data-val=11>11:00</text>
								<text :class="[this.xmstime=='12'?'item-text_on':'']" @click="xmstimechange"
									data-val=12>12:00</text>
								<text :class="[this.xmstime=='13'?'item-text_on':'']" @click="xmstimechange"
									data-val=13>13:00</text>
								<text :class="[this.xmstime=='14'?'item-text_on':'']" @click="xmstimechange"
									data-val=14>14:00</text>
								<text :class="[this.xmstime=='15'?'item-text_on':'']" @click="xmstimechange"
									data-val=15>15:00</text>
								<text :class="[this.xmstime=='16'?'item-text_on':'']" @click="xmstimechange"
									data-val=16>16:00</text>
								<text :class="[this.xmstime=='17'?'item-text_on':'']" @click="xmstimechange"
									data-val=17>17:00</text>
								<text :class="[this.xmstime=='18'?'item-text_on':'']" @click="xmstimechange"
									data-val=18>18:00</text>
								<text :class="[this.xmstime=='19'?'item-text_on':'']" @click="xmstimechange"
									data-val=19>19:00</text>
								<text :class="[this.xmstime=='20'?'item-text_on':'']" @click="xmstimechange"
									data-val=20>20:00</text>
							</view>
						</scroll-view>
					</view>
					<view style="flex: 1 1 0%; text-align: center;">至</view>
					<view class="data-star">
						<view class="data-item-title">结束时间</view>
						<scroll-view scroll-y="true" style="height: 200rpx;">
							<view class="data-item-text">
								<text :class="[this.xmetime=='8'?'item-text_on':'']" @click="xmetimechange"
									data-val=8>08:00</text>
								<text :class="[this.xmetime=='9'?'item-text_on':'']" @click="xmetimechange"
									data-val=9>09:00</text>
								<text :class="[this.xmetime=='10'?'item-text_on':'']" @click="xmetimechange"
									data-val=10>10:00</text>
								<text :class="[this.xmetime=='11'?'item-text_on':'']" @click="xmetimechange"
									data-val=11>11:00</text>
								<text :class="[this.xmetime=='12'?'item-text_on':'']" @click="xmetimechange"
									data-val=12>12:00</text>
								<text :class="[this.xmetime=='13'?'item-text_on':'']" @click="xmetimechange"
									data-val=13>13:00</text>
								<text :class="[this.xmetime=='14'?'item-text_on':'']" @click="xmetimechange"
									data-val=14>14:00</text>
								<text :class="[this.xmetime=='15'?'item-text_on':'']" @click="xmetimechange"
									data-val=15>15:00</text>
								<text :class="[this.xmetime=='16'?'item-text_on':'']" @click="xmetimechange"
									data-val=16>16:00</text>
								<text :class="[this.xmetime=='17'?'item-text_on':'']" @click="xmetimechange"
									data-val=17>17:00</text>
								<text :class="[this.xmetime=='18'?'item-text_on':'']" @click="xmetimechange"
									data-val=18>18:00</text>
								<text :class="[this.xmetime=='19'?'item-text_on':'']" @click="xmetimechange"
									data-val=19>19:00</text>
								<text :class="[this.xmetime=='20'?'item-text_on':'']" @click="xmetimechange"
									data-val=20>20:00</text>
							</view>
						</scroll-view>
					</view>
				</view>
				<view class="data-btn">
					<button type="primary" @click="queren('xmtime')">确定</button>
					<button type="primary" plain="true" @click="xmquantian">默认全天</button>
				</view>
			</view>
		</uni-popup>
	</view>

</template>

<script>
	import tabControl from '@/components/tabControl-tag/choose-tabControl.vue';
	import uniPopup from "@/components/uni-popup/uni-popup.vue"
	// import EvanCheckbox from '@/components/evan-checkbox/evan-checkbox.vue'
	// import EvanCheckboxGroup from "@/components/evan-checkbox/evan-checkbox-group.vue"
	import data_newstype from '@/common/static/data-newstype.js';
	import data_xiangmujieduan from '@/common/static/data-xiangmujieduan.js';
	import commonjs from '@/common/script/common.js';
	// 地区联动
	// import region from "data";
	var dingyueid = 0;
	var dingyuetype = 0;
	export default {
		components: {
			tabControl,
			uniPopup
			//EvanCheckbox,
			//EvanCheckboxGroup
		},
		data() {
			return {
				startX: 0, // 记录开始触摸点的X坐标
				lastX: 0, // 记录上一次触摸点的X坐标
				isshowInfoSwitch:false,

				// 存储初始化页面时的表单初始值
				initBx: {
					// keyword:'',
					// newstype,
					// fanwei,
					// newsdiqu,
					// appswitch,
					// infoswitch,
					// stime,
					// etime,  
					// // =0全天
					// apptype,
				},
				// 存储初始化时项目的表单初始值
				initXm: {
					// xiangmudiqu,
					// xiangmutype,
					// xmjieduan,
					// yewudesc,
					// xmswitch,
					// infoswitch,
					// xmstime,
					// xmetime,
					// // xmapptype 0 全天
					// xmapptype,
				},
				// 以下3个字段用于数据更新（通过跳转新页面进行修改）时用到，之所以不用keyword,xiangmutype,yewudesc，原因是这三个字段还用于是否修改的比对，而修改时的新页面会直接修改this.data中的数据，不能区分出字段是否修改过
				keywordedit: '',
				xiangmutypeedit: '',
				yewudescedit: '',

				type: '',
				isaddorupdate: 0, //1：添加 2：修改
				items: ['招标信息订阅', '工程信息订阅'],
				current: 0,
				currentquyu: '', //当前关注地区
				choosediqu: '', //所选地区
				currentfanwei: 0, //当前范围
				//查询范围
				querys: [{
						value: '0',
						name: '全文加标题'
					},
					{
						value: '1',
						name: '全文'
					},
					{
						value: '2',
						name: '标题'
					}
				],
				appswitch: true,
				infoswitch: false,
				phases: data_xiangmujieduan.jieduanList,
				infortypes: data_newstype.tabListNoBiaoshu,
				newsdiqu: ['全国'],
				newstype: ['9999'],
				typestr: '',
				checked: true,
				typechecked: true,
				searchfanwei: null,
				keyword: '', //关键词
				fanwei: '全文加标题', //查询范围
				stime: 8,
				etime: 20,
				apptype: 1,
				deviceid: '',
				xiangmutype: ['0'],
				xiangmudiqu: ['全国'],
				xiangmudiquPrev: ['全国'],
				xiangmucurrentquyu: '全国',
				xmswitch: true,
				xmstime: 8,
				xmetime: 20,
				xmapptype: 1,
				yewudesc: '',
				xmjieduan: ['all'],
				xmjdPrev:['all'],
				area: [{
					"全国": {
						"val": 0,
						"items": [{
							value: '全国',
							title: '全国',
							code: ''
						}]
					},
					"华东": {
						"val": 1,
						"items": [{
							value: '上海',
							title: '上海',
							code: '310000'
						}, {
							value: '江苏',
							title: '江苏',
							code: '320000'
						}, {
							value: '浙江',
							title: '浙江',
							code: '330000'
						}, {
							value: '安徽',
							title: '安徽',
							code: '340000'
						}, {
							value: '福建',
							title: '福建',
							code: '350000'
						}, {
							value: '江西',
							title: '江西',
							code: '360000'
						}, {
							value: '山东',
							title: '山东',
							code: '370000'
						}, {
							value: '台湾',
							title: '台湾',
							code: '710000'
						}]
					},
					"华北": {
						"val": 2,
						"items": [{
							value: '北京',
							title: '北京',
							code: '110000'
						}, {
							value: '天津',
							title: '天津',
							code: '120000'
						}, {
							value: '河北',
							title: '河北',
							code: '130000'
						}, {
							value: '山西',
							title: '山西',
							code: '140000'
						}, {
							value: '内蒙古',
							title: '内蒙古',
							code: '150000'
						}]
					},
					"东北": {
						"val": 3,
						"items": [{
							value: '辽宁',
							title: '辽宁',
							code: '210000'
						}, {
							value: '吉林',
							title: '吉林',
							code: '220000'
						}, {
							value: '黑龙江',
							title: '黑龙江',
							code: '230000'
						}]
					},
					"华南": {
						"val": 4,
						"items": [{
							value: '广东',
							title: '广东',
							code: '440000'
						}, {
							value: '广西',
							title: '广西',
							code: '450000'
						}, {
							value: '海南',
							title: '海南',
							code: '460000'
						}, {
							value: '香港',
							title: '香港',
							code: '810000'
						}, {
							value: '澳门',
							title: '澳门',
							code: '820000'
						}]
					},
					"西北": {
						"val": 5,
						"items": [{
							value: '陕西',
							title: '陕西',
							code: '610000'
						}, {
							value: '甘肃',
							title: '甘肃',
							code: '620000'
						}, {
							value: '青海',
							title: '青海',
							code: '630000'
						}, {
							value: '宁夏',
							title: '宁夏',
							code: '640000'
						}, {
							value: '新疆',
							title: '新疆',
							code: '650000'
						}]

					},
					"西南": {
						"val": 6,
						"items": [{
							value: '重庆',
							title: '重庆',
							code: '500000'
						}, {
							value: '四川',
							title: '四川',
							code: '510000'
						}, {
							value: '贵州',
							title: '贵州',
							code: '520000'
						}, {
							value: '云南',
							title: '云南',
							code: '530000'
						}, {
							value: '西藏',
							title: '西藏',
							code: '540000'
						}, ]

					},
					"华中": {
						"val": 7,
						"items": [{
								value: '河南',
								title: '河南',
								code: '410000'
							},
							{
								value: '湖北',
								title: '湖北',
								code: '420000'
							},
							{
								value: '湖南',
								title: '湖南',
								code: '430000'
							}
						]
					},
				}],
				arealist: [],
				xiangmuarealist: [{
					value: '全国',
					title: '全国'
				}],
				regionJson: this.areas,
				currCheckedArea: [],
				cityCheckedArray: [],
				areacodeArray: [] ,//地区编码,省：两位 市：四位 
				currentValue:false,
				newstypePrev:['9999'],
			};
		},
		onLoad: function(options) {
			this.isshowInfoSwitch = this.userInfo.isHuiyuan && !this.userInfo.isPcHuiyuan ? true : false;

			// this.checkLogin(1);
			dingyueid = options.id;
			dingyuetype = options.type;
			this.isaddorupdate = options.isaddorupdate; //1：添加 2：修改
			//console.log(dingyuetype);
			if (dingyuetype === '0') {
				uni.setNavigationBarTitle({
					title: '招标信息订阅'
				});
			} else {
				uni.setNavigationBarTitle({
					title: '工程信息订阅'
				});
			}

			if (this.isaddorupdate == 2) {
				if (dingyueid <= 0 || dingyueid == undefined || dingyuetype == undefined) {
					uni.showToast({
						title: "获取订阅id失败",
						icon: "none",
						success: function() {
							setTimeout(function() {
								uni.switchTab({
									url: '/pages/user/custom/custom',
								});
							}, 2000)
						}
					});
					return;
				} else {
					if (dingyuetype == 0) {
						this.current = 0;
						this.bindData(dingyueid);
					} else if (dingyuetype == 1) {
						this.current = 1;
						this.xmbindData(dingyueid);
					}
				}
			} else if (this.isaddorupdate == 1) {
				if (dingyuetype == 1) {
					this.current = 1;
				}
			} else {
				uni.showToast({
					title: "获取标识失败",
					icon: "none",
					success: function() {
						setTimeout(function() {
							uni.switchTab({
								url: '/pages/user/custom/custom',
							});
						}, 2000)
					}
				});
			}
		},
		onShow: function() {
			// 用于新增时的保存数据比对
			this.initBx = JSON.parse(JSON.stringify({
				keyword: this.keyword,
				newstype: this.newstype,
				fanwei: this.fanwei,
				newsdiqu: this.newsdiqu,
				appswitch: this.appswitch,
				infoswitch: this.infoswitch,
				stime: this.stime,
				etime: this.etime,
				// =0全天
				apptype: this.apptype,
			}))
			// console.log('show',this.initBx)
			// 存储初始化时项目的表单初始值
			this.initXm =JSON.parse(JSON.stringify( {
				xiangmudiqu: this.xiangmudiqu,
				xiangmutype: this.xiangmutype,
				xmjieduan: this.xmjieduan,
				yewudesc: this.yewudesc,
				xmswitch: this.xmswitch,
				// infoswitch: this.infoswitch,
				xmstime: this.xmstime,
				xmetime: this.xmetime,
				// xmapptype 0 全天
				xmapptype: this.xmapptype,
			}))

			// this.checkLogin(1);
			let pages = getCurrentPages();
			let currPage = pages[pages.length - 1];
			if (currPage.keywordedit != undefined && currPage.keywordedit != '' && currPage.keywordedit != null)
				this.keyword = currPage.keywordedit;
			if (currPage.xiangmutypeedit != undefined && currPage.xiangmutypeedit != null && currPage.xiangmutypeedit.length > 0)
				this.xiangmutype = currPage.xiangmutypeedit;
			if (currPage.yewudescedit != undefined && currPage.yewudescedit != null)
				this.yewudesc = decodeURIComponent(currPage.yewudescedit);

			// console.log(11,this.initXm)
		},
		/**
		 * 触发返回行为的来源：'backbutton'——左上角导航栏按钮及安卓返回键；'navigateBack'——uni.navigateBack() 方法。支付宝小程序端不支持返回此字段
		 * 注：iOS 端侧滑返回不会触发(android则会) onBackPress
		 * 注：侧滑通过监听 @touchstart 相关方法实现，另：如果用户从手机最左侧开始滑动，会成功返回上一个页面，弹窗不能阻止返回，故此时不提示保存弹窗（只有this.lastX>10时会提示保存弹窗，即只走页面中的滑动）
		 * 
		 * 点击返回时，返回手势/底部返回按钮时，需要判断是否内容有修改
		 */
		// onHide(){

		// },
		// onUnload(e){

		// },
		onBackPress(options) {
			// console.log('from:' + options.from)
			if (options.from) {
				const ret = this.savePop();
				return ret;
			}
		},
		methods: {
			// 触摸开始事件
			onTouchStart(event) {
				this.startX = event.touches[0].pageX; // 获取触摸点的X坐标
			},
			// 触摸移动事件
			onTouchMove(event) {
				this.lastX = event.touches[0].pageX; // 获取上一次触摸点的X坐标
			},
			// 触摸结束事件
			onTouchEnd(event) {
				// this.lastX = event.touches[0].pageX; // 获取上一次触摸点的X坐标
				// console.log(1, this.startX, this.lastX, this.lastX - this.startX)
				// 左滑，注：为了防止点击的手机侧滑完成后显示上一个页面时显示弹窗，添加 this.lastX>0的条件，即左边开始滑动的起点尽量保证在页面中
				if ((this.lastX - this.startX) > 0 && this.lastX > 10) { // 判断是否向左滑动，可以根据需要调整50的数值
					this.savePop(); // 显示保存表单的提示
				}
			},
			// 返回时保存表单
			savePop() {
				// 表单是否更改过，注：招标中的 关键词 及项目中的 项目类型 客户主营业务描述 都是跳转页面编辑内容的，需要单独处理
				// this.initBx this.initXm
				// 最终参数
				const {
					keyword,
					newstype,
					fanwei,
					newsdiqu,
					appswitch,
					infoswitch,
					stime,
					etime,
					// =0全天
					apptype,
				} = this;
				const endBx = {
					keyword,
					newstype,
					fanwei,
					newsdiqu,
					appswitch,
					infoswitch,
					stime,
					etime,
					// =0全天
					apptype,
				}
				const {
					xiangmudiqu,
					xiangmutype,
					xmjieduan,
					yewudesc,
					xmswitch,
					xmstime,
					xmetime,
					// xmapptype 0 全天
					xmapptype,
				} = this;
				const endXm = {
					xiangmudiqu,
					xiangmutype,
					xmjieduan,
					yewudesc,
					xmswitch,
					// infoswitch,
					xmstime,
					xmetime,
					// xmapptype 0 全天
					xmapptype,
				}
				// console.log(2,this.initXm.xiangmutype,endXm.xiangmutype)
				let isneedsave = false;
				if (dingyuetype === '0') {
					isneedsave = JSON.stringify(this.initBx) !== JSON.stringify(endBx)
				} else {
					isneedsave = JSON.stringify(this.initXm) !== JSON.stringify(endXm)
				}

				if (isneedsave) {
					uni.showModal({
						title: '',
						content: '是否保存当前修改内容',
						cancelText: '取消',
						confirmText: '保存',
						success: res => {
							if (res.confirm) {
								// 保存	
								if (dingyuetype === '0') {
									this.submit_zhaobiao();
								} else {
									this.submit_xiangmu();
								}

							} else if (res.cancel) {
								uni.switchTab({
									url: '/pages/user/custom/custom'
								});
							}
							this.startX = 0
							this.lastX = 0
						}
					})
					return true
				}
			},
			//切换地区
			// diquchange(e) {
			// 	this.currentquyu = e;
			// 	this.arealist = this.area[0][e].items;
			// 	//console.log(this.arealist);
			// },
			diquchange(e) {
				if (e) {
					this.currentquyu = e.region_id;
					this.arealist = this.objToArr(this.regionJson[e.region_id].child);
					//console.log(this.arealist)
					this.arealist = this.arealist.filter(item => {
						return (item.region_name != "县" && item.region_name != "省直辖县级行政区划" && item.region_name !=
							"自治区直辖县级行政区划");
					})
					//console.log(this.arealist)
				} else {
					this.currentquyu = "";
					this.arealist = [];
					this.currCheckedArea = [];
					this.cityCheckedArray = []
				}
			},
			cityChange(e) {
				if (e) {
					if (this.isInArray(this.cityCheckedArray, e.region_id)) {
						this.cityCheckedArray = this.cityCheckedArray.filter(item => {
							return item != e.region_id;
						})
					} else {
						this.cityCheckedArray.push(e.region_id);
					}

				} else {
					if (this.checkAllCity(this.currentquyu)) {
						this.arealist.forEach(itemarea => {
							this.cityCheckedArray = this.cityCheckedArray.filter(item => {
								return itemarea.region_id != item;
							})
						})
					} else {
						this.arealist.forEach(item => {
							if (!this.isInArray(this.cityCheckedArray, item.region_id)) {
								this.cityCheckedArray.push(item.region_id)
							}
						})
					}
				}
				//判断当前省份是否已经存在
				//console.log(this.cityCheckedArray)
				var hascurrsheng = false
				for (var i = 0; i < this.currCheckedArea.length; i++) {
					if (this.currCheckedArea[i].region_id == this.currentquyu) {
						hascurrsheng = true;
						break;
					}
				}
				var area = [];
				this.arealist.forEach(item => {
					if (this.isInArray(this.cityCheckedArray, item.region_id)) {
						area.push(item.region_id)
					}
				})
				// console.log(area)
				// console.log(this.regionJson[this.currentquyu].child)
				// console.log(this.regionJson[this.currentquyu].child.length)
				var isall = (area.length >= this.arealist.length);
				if (hascurrsheng) {
					this.currCheckedArea.forEach(item => {
						if (item.region_id == this.currentquyu) {
							item.child = area;
							item.isall = isall;
						}
					})
				} else {
					var obj = {};
					obj.region_id = this.currentquyu;
					obj.child = area;
					obj.isall = isall;
					this.currCheckedArea.push(obj)
				}
				if (area.length <= 0) {
					this.currCheckedArea = this.currCheckedArea.filter(item => {
						return item.region_id != this.currentquyu;
					})
				}
				// console.log(this.currCheckedArea)
				// console.log(this.cityCheckedArray)

			},
			onDiquChange(evt) { //所选地区
				if (evt[evt.length - 1] == '全国') {
					this.newsdiqu = ['全国'];
				}
				if (this.newsdiqu.length > 1) {
					if (this.isInArray(this.newsdiqu, "全国")) {
						this.newsdiqu = this.newsdiqu.filter(item => {
							return item != '全国';
						})
					}
				}
			},

			checkAllCity(code) { //判断当前地区是否为全选
				var flag = false;
				if (this.currCheckedArea && this.currCheckedArea.length > 0) {
					this.currCheckedArea.forEach(item => {
						if (item.region_id == code) {
							flag = item.isall;
							return flag;
						}
					})
				}
				return flag;
			},
			checkCurrentProvince(code) { //判断当前省份是否被选中
				var flag = false;
				if (this.currCheckedArea && this.currCheckedArea.length > 0) {
					for (var i = 0; i < this.currCheckedArea.length; i++) {
						if (this.currCheckedArea[i].region_id == code && this.currCheckedArea[i].region_id != this
							.currentquyu) {
							flag = true;
							break;
						}
					}
				}
				return flag;
			},
			xiangmudiquchange(e) {
				this.xiangmucurrentquyu = e;
				this.xiangmuarealist = this.area[0][e].items;
			},
			onXiangmuDiquChange(evt) { //所选地区
				// if (evt[evt.length - 1] == '全国') {
				// 	this.xiangmudiqu = ['全国'];
				// }
				// if (this.xiangmudiqu.length > 1) {
				// 	if (this.isInArray(this.xiangmudiqu, "全国")) {
				// 		this.xiangmudiqu = this.xiangmudiqu.filter(item => {
				// 			return item != '全国';
				// 		})
				// 	}
				// }
				
				if (evt.includes('全国')) {
					if (this.isInArray(this.xiangmudiquPrev, "全国")) {
						this.xiangmudiqu = evt.filter(i => i !== '全国')
					} else {
						this.xiangmudiqu = ['全国']
					}
					this.xiangmudiquPrev = this.xiangmudiqu
				}
			},
			xmjieduanChange(evt) {
				// if (evt[evt.length - 1] == 'all') {
				// 	this.xmjieduan = ['all'];
				// }
				// if (this.xmjieduan.length > 1) {
				// 	if (this.isInArray(this.xmjieduan, "all")) {
				// 		this.xmjieduan = this.xmjieduan.filter(item => {
				// 			return item != 'all';
				// 		})
				// 	}
				// }
				
				if (evt.includes('all')) {
					if (this.isInArray(this.xmjdPrev, "all")) {
						this.xmjieduan = evt.filter(i => i !== 'all')
					} else {
						this.xmjieduan = ['all']
					}
					this.xmjdPrev = this.xmjieduan
				}
			},
			onGroupChange(e) { //信息类型
			 //    if (e[0] == '9999' && !e.length) {
				// 	this.newstype = ['9999'];
				// }
				// if (this.newstype.length > 1) {
				// 	if (this.isInArray(this.newstype, "9999")) {
				// 		this.newstype = this.newstype.filter(item => {
				// 			return item != '9999';
				// 		})
				// 	}
				// }
				
				
				if (e.includes('9999')) {
					if (this.isInArray(this.newstypePrev, "9999")) {
						this.newstype = e.filter(i => i !== '9999')
					} else {
						this.newstype = ['9999']
					}
					this.newstypePrev = this.newstype
				}
			},
			resetbutton(type) {
				if (type == "diqu")
					this.diquchange();
				else if (type == "leixing")
					this.newstype = []
				else if (type == "xmdiqu")
					this.xiangmudiqu = []
			},
			queren(type) {
				if (type == "diqu") {
					var tempdiqu = this.newsdiqu;
					var tempareacode = this.areacodeArray;
					this.areacodeArray = [];
					if (this.currCheckedArea && this.currCheckedArea.length > 0) {
						this.newsdiqu = [];
						for (var i = 0; i < this.currCheckedArea.length; i++) {
							//拼接地区code，方便后台查询
							if (this.currCheckedArea[i].isall) {
								if (this.currCheckedArea[i].region_id.length == 6) {
									this.newsdiqu.push(this.regionJson[this.currCheckedArea[i].region_id]
										.region_name);
									this.areacodeArray.push(this.currCheckedArea[i].region_id.substr(0, 2))
								}
							} else {
								if (this.currCheckedArea[i].child && this.currCheckedArea[i].child.length > 0) {
									this.currCheckedArea[i].child.forEach(item => {
										if (item.length == 6) {
											this.areacodeArray.push(item.substr(0, 4))
											this.newsdiqu.push(this.regionJson[this.currCheckedArea[
												i].region_id].child[item].region_name)
										}
									})
								}
							}
						}
					} else {
						this.newsdiqu = ['全国'];
					}
					if (this.areacodeArray.length > 20) {
						this.newsdiqu = tempdiqu;
						this.areacodeArray = tempareacode;
						uni.showToast({
							title: '地区最多可选择20个！',
							icon: "none"
						});
						return false;
					}
					this.cancel("popup2");
				} else if (type == "xmdiqu") {
					this.cancel("popup5");
				} else if (type == "leixing") {
					this.cancel("share");
				} else if (type == "time") {
					if (this.stime > 0 && this.etime > 0) {
						if (this.stime >= this.etime) {
							uni.showToast({
								title: "开始时间必须小于结束时间",
								icon: "none"
							});
							return false;
						}
						this.apptype = 1;
						this.cancel("popup3");
					} else if (this.stime > 0 && this.etime == 0) {
						uni.showToast({
							title: "请选择结束时间",
							icon: "none"
						});
						return false;
					} else if (this.stime == 0 && this.etime > 0) {
						uni.showToast({
							title: "请选择开始时间",
							icon: "none"
						});
						return false;
					} else {
						this.apptype = 0;
						this.cancel("popup3");
					}
				} else if (type == "xmtime") {
					if (this.xmstime > 0 && this.xmetime > 0) {
						if (this.xmstime >= this.xmetime) {
							uni.showToast({
								title: "开始时间必须小于结束时间",
								icon: "none"
							});
							return false;
						}
						this.xmapptype = 1;
						this.cancel("popup6");
					} else if (this.xmstime > 0 && this.xmetime == 0) {
						uni.showToast({
							title: "请选择结束时间",
							icon: "none"
						});
						return false;
					} else if (this.xmstime == 0 && this.xmetime > 0) {
						uni.showToast({
							title: "请选择开始时间",
							icon: "none"
						});
						return false;
					} else {
						this.xmapptype = 0;
						this.cancel("popup6");
					}
				} else if (type == 'fanwei') {
					this.cancel("popup");
				} else if (type == 'jieduan') {
					this.cancel("popup4");
				}
			},
			stimechange(e) {
				this.stime = parseInt(e.target.dataset.val);
			},
			etimechange(e) {
				this.etime = parseInt(e.target.dataset.val);
			},
			xmstimechange(e) {
				this.xmstime = parseInt(e.target.dataset.val);
			},
			xmetimechange(e) {
				this.xmetime = parseInt(e.target.dataset.val);
			},
			quantian() { //默认全天
				this.stime = 0;
				this.etime = 0;
				this.apptype = 0;
				this.cancel("popup3");
			},
			xmquantian() { //默认全天
				this.xmstime = 0;
				this.xmetime = 0;
				this.xmapptype = 0;
				this.cancel("popup6");
			},
			bindData(id) {
				if (id <= 0) {
					uni.showToast({
						title: "获取订阅id失败",
						icon: "none"
					});
				}
				//异步请求数据
				let data = this.initNewData();
				data.from = 4038;
				data.location = 5128;
				data.id = dingyueid;
				uni.request({
					url: this.baseConfig.serverURL + 'User/custom/edit.ashx', //检查更新的服务器地址
					data: data,
					method: "POST",
					header: {
						"content-type": "application/x-www-form-urlencoded" //"application/json"
					},
					success: (res) => {
						if (res.statusCode == 200) {
							if (!res.data.ret) {
								// uni.showToast({
								// 	title: res.data.msg,
								// 	icon: "none"
								// });
								return;
							} else {
								//获取成功，绑定
								let list = res.data.other2;
								if (list == undefined || list == null) {
									uni.showToast({
										title: "数据加载失败",
										icon: "none"
									});
									return;
								}


								this.keyword = list.keyword;
								
								this.appswitch = (list.appstatus == 0 ? true : false);
								// 默认0 关闭 1在手机号已通过验证的前提下开启
								this.infoswitch=list.mbstate===1?true:false;
								
								
								if (this.newstype.length <= 0){
									this.newstype = ['9999'];
								}else{
									this.newstype = list.type.split(',');
								}
									
									
								this.currentfanwei = list.tag;
								this.fanwei = this.fanweiTostr(list.tag);
								this.newsdiqu = list.diqu.split(',');
								this.typestr = list.typeStr;
								this.choosediqu = list.diqu;
								this.stime = list.stime;
								this.etime = list.etime;
								this.apptype = list.apptype;
								const {
									keyword,
									newstype,
									fanwei,
									newsdiqu,
									appswitch,
									infoswitch,
									stime,
									etime,
									// =0全天
									apptype,
								} = this;
								this.initBx = Object.assign({},{
									keyword,
									newstype:JSON.parse(JSON.stringify(newstype)),
									fanwei,
									newsdiqu:JSON.parse(JSON.stringify(newsdiqu)),
									appswitch,
									infoswitch,
									stime,
									etime,
									// =0全天
									apptype,
								})
								if (list.areacode && list.areacode != "")
									this.areacodeArray = list.areacode.split(',');
								this.bindAreaData(this.areacodeArray);
							}
						} else {
							uni.showToast({
								title: '数据加载失败',
								icon: "none"
							});
						}
					},
					fail: (res) => {
						uni.showToast({
							title: '数据加载失败，可能已超时！',
							icon: "none"
						});
					}
				})

			},
			bindAreaData(codeArray) {
				if (codeArray && codeArray.length > 0) {
					var CheckedArea = [];
					codeArray.forEach(item => {
						if (item.length == 2) { //省
							var code = item + "0000";
							var area = [];
							var child = this.objToArr(this.regionJson[code].child);
							child = child.filter(item => {
								return (item.region_name != "县" && item.region_name !=
									"自治区直辖县级行政区划");
							})
							child.forEach(item => {
								area.push(item.region_id)
							})
							var obj = {};
							obj.region_id = code;
							obj.child = area;
							obj.isall = true;
							CheckedArea.push(obj);

						} else if (item.length == 4) { //市
							var ProvinceCode = item.substr(0, 2) + "0000";
							var CityCode = item + "00";
							var area = [];
							this.arealist.forEach(item => {
								if (this.isInArray(this.cityCheckedArray, item
										.region_id)) {
									area.push(item.region_id)
								}
							})
							var hascurrsheng = false
							for (var i = 0; i < CheckedArea.length; i++) {
								if (CheckedArea[i].region_id == ProvinceCode) {
									hascurrsheng = true;
									break;
								}
							}
							if (hascurrsheng) {
								CheckedArea.forEach(item => {
									if (item.region_id == ProvinceCode) {
										item.child.push(CityCode);
									}
								})
							} else {
								var obj = {};
								obj.region_id = ProvinceCode;
								obj.child = [CityCode];
								obj.isall = false;
								CheckedArea.push(obj)
							}
						}
					})
					if (CheckedArea.length > 0) {
						//默认选中第一个省份
						this.currentquyu = CheckedArea[0].region_id;
						this.arealist = this.objToArr(this.regionJson[CheckedArea[0].region_id]
							.child);
						this.arealist = this.arealist.filter(item => {
							return (item.region_name != "县" && item
								.region_name != "省直辖县级行政区划" && item
								.region_name !=
								"自治区直辖县级行政区划");
						})
						CheckedArea.forEach(item => {
							this.cityCheckedArray = this.cityCheckedArray.concat(item.child)
						})
						this.currCheckedArea = CheckedArea;
					}
				}
			},
			xmbindData(id) {
				if (id <= 0) {
					uni.showToast({
						title: "获取工程订阅信息id失败",
						icon: "none"
					});
				}
				//异步请求数据
				let data = this.initNewData();
				data.from = 4038;
				data.location = 5128;
				data.id = dingyueid;
				uni.request({
					url: this.baseConfig.serverURL + 'User/custom/xmEditHandler.ashx', //检查更新的服务器地址
					data: data,
					method: "POST",
					header: {
						"content-type": "application/x-www-form-urlencoded" //"application/json"
					},
					success: (res) => {
						//console.log(res);
						if (res.statusCode == 200) {
							if (!res.data.ret) {
								uni.showToast({
									title: res.data.msg,
									icon: "none"
								});
								return;
							} else {
								//获取成功，绑定
								let list = res.data.other2;
								// console.log(list);
								if (list == undefined || list == null) {
									uni.showToast({
										title: "数据加载失败",
										icon: "none"
									});
									return;
								}
								this.xiangmudiqu = list.diqu.split(',');
								if (this.xiangmudiqu.length <= 0)
									this.xiangmudiqu = ['全国']
								
								this.xmswitch = (list.status == 0 ? true : false);
								// 默认0 关闭 1在手机号已通过验证的前提下开启
								// this.infoswitch=list.mbstate===1?true:false;
								
								this.xiangmutype = list.xmtype.split(',');
								if (this.xiangmutype.length <= 0)
									this.xiangmutype = ['0']
								this.xmjieduan = list.jieduan.split(',');
								if (this.xmjieduan.length <= 0)
									this.xmjieduan = ['all']
								this.yewudesc = list.yewu;
								this.xmstime = list.stime;
								this.xmetime = list.etime;
								this.xmapptype = list.apptype;

								const {
									xiangmudiqu,
									xiangmutype,
									xmjieduan,
									yewudesc,
									xmswitch,
									infoswitch,
									xmstime,
									xmetime,
									// xmapptype 0 全天
									xmapptype,
								} = this;
								this.initXm = {
									xiangmudiqu:JSON.parse(JSON.stringify(xiangmudiqu)),
									xiangmutype:JSON.parse(JSON.stringify(xiangmutype)),
									xmjieduan:JSON.parse(JSON.stringify(xmjieduan)),
									yewudesc,
									xmswitch,
									// infoswitch,
									xmstime,
									xmetime,
									// xmapptype 0 全天
									xmapptype,
								}

							}
						} else {
							uni.showToast({
								title: '数据加载失败',
								icon: "none"
							});
						}
					},
					fail: (res) => {
						uni.showToast({
							title: '数据加载失败，可能已超时！',
							icon: "none"
						});
					}
				})
			},
			submit_zhaobiao() {
				//异步请求数据
				let data = this.initNewData();
				data.from = 4038;
				data.location = 5128;
				data.id = dingyueid;
				data.isaddorupdate = this.isaddorupdate;
				data.keyword = this.keyword;
				if (data.keyword.length > 80) {
					uni.showToast({
						title: "订阅的关键词总长度不能超过80个字",
						icon: "none"
					});
					return false;
				}
				data.typestr = this.newstype.toString() == '9999' ? '' : this.newstype.toString();
				data.currentfanwei = this.currentfanwei;
				data.choosediqu = this.newsdiqu.toString();
				data.areacode = this.areacodeArray.toString();
				data.appswitch = this.appswitch ? 0 : 1;
				// 默认0 关闭 1在手机号已通过验证的前提下开启
				data.mbstate=this.infoswitch?1:0;
				data.stime = this.stime;
				data.etime = this.etime;
				data.apptype = this.apptype;
				data.deviceid = this.deviceid;
				uni.request({
					url: this.baseConfig.serverURL + 'User/custom/add.ashx', //检查更新的服务器地址
					data: data,
					method: "POST",
					header: {
						"content-type": "application/x-www-form-urlencoded" //"application/json"
					},
					success: (res) => {
						//console.log(res);
						if (res.statusCode == 200) {
							if (!res.data.ret) {
								if (this.baseConfig.isIOSshenhe) {
									if (res.data.msg.includes('最多订阅5条')) {
										uni.showToast({
											title: "您最多可订阅5条",
											icon: "none"
										});
									}
									return
								}
								uni.showToast({
									title: res.data.msg,
									icon: "none"
								});
								return;
							} else {
								//成功，绑定
								uni.showToast({
									title: res.data.msg,
									icon: "none",
									success: function() {
										setTimeout(function() {
											uni.switchTab({
												url: '/pages/user/custom/custom',
											});
										}, 2000)
									}
								});
							}
						} else {
							uni.showToast({
								title: '提交失败!',
								icon: "none"
							});
						}
					},
					fail: (res) => {
						uni.showToast({
							title: '提交失败，可能已超时！',
							icon: "none"
						});
					}
				})
			},
			submit_xiangmu() {
				//异步请求数据
				let data = this.initNewData();
				data.from = 4038;
				data.location = 5128;
				data.id = dingyueid;
				data.isaddorupdate = this.isaddorupdate;
				data.diqu = this.xiangmudiqu.toString() == '全国' ? '' : this.xiangmudiqu.toString();
				var code = '';
				for (var i = 0; i < this.xiangmudiqu.length; i++) {
					code += commonjs.getAreaCode(this.xiangmudiqu[i]) + ","
				}
				if (code != '')
					code = code.substring(0, code.lastIndexOf(','));
				data.diqucode = code;
				data.xmtype = this.xiangmutype.toString() == '0' ? '' : this.xiangmutype.toString();
				data.jieduantype = this.xmjieduan.toString() == 'all' ? '' : this.xmjieduan.toString();
				data.xmswitch = this.xmswitch ? 0 : 1;
				data.yewu = this.yewudesc;
				data.xmstime = this.xmstime;
				data.xmetime = this.xmetime;
				data.tuisongtype = this.xmapptype;
				data.deviceid = this.deviceid;
				uni.request({
					url: this.baseConfig.serverURL + 'User/custom/xmAddHandler.ashx', //检查更新的服务器地址
					data: data,
					method: "POST",
					header: {
						"content-type": "application/x-www-form-urlencoded" //"application/json"
					},
					success: (res) => {
						//console.log(res);
						if (res.statusCode == 200) {
							if (!res.data.ret) {
								if (this.baseConfig.isIOSshenhe) {
									if (res.data.msg.includes('最多订阅5条')) {
										uni.showToast({
											title: "您最多可订阅5条",
											icon: "none"
										});
									}
									return
								}
								uni.showToast({
									title: res.data.msg,
									icon: "none"
								});
								return;
							} else {
								//成功，绑定
								uni.showToast({
									title: res.data.msg,
									icon: "none",
									success: function() {
										setTimeout(function() {
											uni.switchTab({
												url: '/pages/user/custom/custom',
											});
										}, 2000)
									}

								});
							}
						} else {
							uni.showToast({
								title: '提交失败！',
								icon: "none"
							});
						}
					},
					fail: (res) => {
						uni.showToast({
							title: '提交失败，可能已超时！',
							icon: "none"
						});
					}
				})
			},
			onClickItem(val) {
				this.current = val.currentIndex;
			},
			scollSwiper(e) {
				return;
				this.current = e.target.current
				// this.savePop();

			},
			appswitchChange(e) {
				this.appswitch = e.value;
			},
			appInfoswitchChange(e) {
				this.infoswitch = e.value;
			},
			switchChange(e) {
				this.xmswitch = e.value;
			},
			togglePopup(type, open) {
				this.type = type
				this.$nextTick(() => {
					this.$refs['show' + open].open()
				})
			},
			keywords() {
				uni.navigateTo({
					url: '../keywords/keywords?keyword=' + this.keyword
				})
			},
			cancel(type) {
				this.$refs['show' + type].close()
			},
			xiangmuhangye() {
				console.log(this.xiangmutype.toString())
				let xiangmutype = this.xiangmutype.toString()
				uni.navigateTo({
					// url: 'pages/user/custom/ProjectType/ProjectType?type=' + xiangmutype
					
					 url:'/pages/user/custom/ProjectType/ProjectType?type=' + xiangmutype
				})
			},
			description() {
				uni.navigateTo({
					url: '../businessDescrip/businessDescrip?yewudesc=' + encodeURIComponent(this.yewudesc)
				})
			},
			toggleCheckbox2(index) {
				this.$refs.listCheckbox2[index].toggle()
			},
			toggleCheckbox3(index) {
				this.$refs.listCheckbox3[index].toggle()
			},
			fanweiradioChange(e) {
				let currObj = this.querys[e.detail.value];
				this.fanwei = currObj.name;
				this.currentfanwei = e.detail.value;
				// console.log(this.currentfanwei);
			},
			radioChange: function(evt) {
				// console.log(this.querys.length);
				// console.log(evt.target.value);
				for (let i = 0; i < this.querys.length; i++) {
					if (this.querys[i].value === evt.target.value) {
						this.current = i;
						break;
					}
				}
			},
			isInArray(arr, value) {
				for (var i = 0; i < arr.length; i++) {
					if (value === arr[i]) {
						return true;
					}
				}
				return false;
			},
			fanweiTostr(type) {
				var str = '';
				switch (type) {
					case 0:
						str = '全文加标题'
						break;
					case 1:
						str = '全文'
						break;
					case 2:
						str = '标题'
						break;
				}
				return str;
			},
			//招标类型
			zhaobiaotypetostr(typeids) {
				var str = '';
				if (typeids != '' && typeids != undefined) {
					var typelist = typeids.split(',');
					if (typelist.length > 0) {
						for (let i = 0; i < typelist.length; i++) {
							if (typelist[i] != '')
								str += data_newstype.typeidtostr(typelist[i]) + ','
						}
					}
				}
				if (str != '')
					str = str.substring(0, str.lastIndexOf(','));
				return str;
			},
			//项目类型
			typetostr(typeids) {
				var str = '';
				if (typeids != '' && typeids != undefined) {
					var typelist = typeids.split(',');
					if (typelist.length > 0) {
						for (let i = 0; i < typelist.length; i++) {
							if (typelist[i] != '')
								str += commonjs.xmTypeToStr(parseInt(typelist[i])) + ','
						}
					}
				}
				if (str != '')
					str = str.substring(0, str.lastIndexOf(','));
				else
					str = '全部类型';
				return str;
			},
			//项目阶段
			jieduantostr(typeids) {
				var str = '';
				if (typeids != '' && typeids != undefined) {
					var typelist = typeids.split(',');
					if (typelist.length > 0) {
						for (let i = 0; i < typelist.length; i++) {
							if (typelist[i] != '')
								str += data_xiangmujieduan.jieduanidtostr(typelist[i]) + ','
						}
					}
				}
				if (str != '')
					str = str.substring(0, str.lastIndexOf(','));
				return str;
			},
			objToArr(obj) {
				const arr = Object.values(obj);
				let list = arr.map((item, index) => {
					return {
						region_id: item.region_id,
						region_name: item.region_name,
						child: item.child,
					};
				});
				return list;
			}
		},
	
	}
</script>

<style lang="scss">
	@import "@/static/css/custom/choose.scss";

	.Information-tabtext-item2 {
		border-bottom: 1px solid #F5F5F5;
	}
	.choose-wrap ::v-deep .uni-list-item__icon-img{
		width: 80rpx;
		height: 80rpx;
	}
	.choose-wrap ::v-deep .uni-list-item__container{
		padding-left:0;
	}
</style>